root@NetStudio:/www/cgi-bin# cat set_gpio.cgi 
#!/bin/sh
# 解析 URL 参数
args=$(echo $QUERY_STRING | sed -e 's/&/\n/g')
gpio=$(echo "$args" | grep '^gpio=' | cut -d '=' -f 2)
value=$(echo "$args" | grep '^value=' | cut -d '=' -f 2)

# 设置 GPIO 值
if [ -w "/sys/class/gpio/gpio$gpio/value" ]; then
    echo "$value" > /sys/class/gpio/gpio$gpio/value
    echo "Content-Type: text/plain"
    echo ""
    echo "GPIO 值设置成功"
else
    echo "Content-Type: text/plain"
    echo ""
    echo "没有权限设置 GPIO 值"
fi
